//
//  WeChatFoundViewController.m
//  ZFJFormKit
//
//  Created by 张福杰 on 2018/4/24.
//  Copyright © 2019 张福杰. All rights reserved.
//

#import "WeChatFoundViewController.h"

#import "ZFJFormKit.h"

@interface WeChatFoundViewController ()

@property (nonatomic,strong) ZFJFormTableView *tableView;
@property (nonatomic,strong) NSMutableArray<NSArray *> *dataArray;

@end

@implementation WeChatFoundViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setBaseBackButtonView];
    [self uiConfig];
}

- (void)uiConfig{
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"发现";
    
    [self.view addSubview:self.tableView];
    
    //CELL的通用配置Model，也可以根据不同的CELL分别配置
    ZFJFormCellConfig *configModel = [[ZFJFormCellConfig alloc] init];
    //左边title
    configModel.titleColor = [UIColor blackColor];
    configModel.titleFont = [UIFont fontWithName:@"PingFangSC-Regular" size:17];
    //左边ICON尺寸（如果有）
    configModel.iconSize = CGSizeMake(25, 25);
    //分割线的颜色
    configModel.separatorLineColor = [UIColor groupTableViewBackgroundColor];
    configModel.isHiddenLine = NO;
    //占位符颜色
    configModel.placeholderColor = [UIColor colorWithRed:0.776 green:0.776 blue:0.800 alpha:1.00];
    //控件左右两边的间距
    configModel.marginSize = 15;
    
    NSArray *titleArr = @[@[@"朋友圈"],@[@"扫一扫", @"摇一摇"],@[@"附近的人"],@[@"小程序"]];
    NSArray *iconArr = @[@[@"weixin_0"],@[@"weixin_1", @"weixin_2"],@[@"weixin_3"],@[@"weixin_4"]];
    for (int i = 0; i<titleArr.count; i++) {
        NSMutableArray *dataArr = [[NSMutableArray alloc] init];
        NSArray *array = [titleArr objectAtIndex:i];
        NSArray *icons = [iconArr objectAtIndex:i];
        for (int j = 0; j<array.count; j++) {
            ZFJFormModel *model = [[ZFJFormModel alloc] init];
            //CELL的类型
            model.formCellType = KFormCellLabelType;
            //CELL的通用配置信息
            model.configModel = configModel;
            //CELL左边的title
            model.title = array[j];
            //CELL的高度
            model.height = 55;
            //CELL左边的ICON图标
            model.iconImg = [UIImage imageNamed:icons[j]];
            //是否显示CELL右边的小箭头
            model.isShowCellRightImg = YES;
            //CELL是否可以点击
            model.isCanSelect = YES;
            //
            [dataArr addObject:model];
        }
        [self.dataArray addObject:dataArr];
    }
    
    self.tableView.sectionsDataArray = self.dataArray;
    
}

- (ZFJFormTableView *)tableView{
    if (_tableView == nil){
        ZFJFormConfig *formConfig = [[ZFJFormConfig alloc] init];
        formConfig.backgroundColor = [UIColor groupTableViewBackgroundColor];
        formConfig.heightFooter = 15.0;
        formConfig.footerViewBgColor = [UIColor groupTableViewBackgroundColor];
        
        _tableView = [[ZFJFormTableView alloc] initWithFrame:CGRectMake(0, KNavBarHei, ZFJForm_ScreenWidth, ZFJForm_ScreenHeight - KNavBarHei) config:formConfig];
        _tableView.didSelectRowBlock = ^(NSIndexPath * _Nullable indexPath, ZFJFormModel * _Nullable model) {
            NSLog(@"%@",model);
        };
    }
    return _tableView;
}

- (NSMutableArray<NSArray *> *)dataArray{
    if (_dataArray == nil){
        _dataArray = [[NSMutableArray alloc] init];
    }
    return _dataArray;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
